package com.zhuiYun.project.api.classifyshops.mapper;

import com.zhuiYun.project.api.classifyshops.entity.BigClassify;
import com.zhuiYun.project.api.classifyshops.entity.Classify;
import com.zhuiYun.project.api.classifyshops.entity.CommodityComment;
import com.zhuiYun.project.api.commoditydetail.entity.Commodity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author 韩佳轩
 * @Date 2023/4/6$ 10:31
 */
@Mapper
public interface ClassifyMapper {

/**
* @Author 韩佳轩
* @Description  全查大分类
* @Date 2023/4/17 15:12
* @Return
* @param bigClassify
*/
@Select("SELECT * from commodity_type where id ")
List<BigClassify> getBigClassify(BigClassify bigClassify);

/**
* @Author 韩佳轩
* @Description 根据大分类id查小分类
* @Date 2023/4/6 10:39
* @Return
* @param
*/
    @Select("SELECT id,type_sname,img_id from commodity_small_type where type_id=#{typeId}")
           List<Classify> getClassify(Classify classify);
/**
* @Author 韩佳轩
* @Description  根据小分类查商品列表
* @Date 2023/4/6 14:33
* @Return Commodity
 * @param
*/
   @Select("<script>SELECT id,commodity_name,favorable_price,image_id from commodity where type_id=#{typeId}" +
           " <when test='commodityName!=&quot;&quot; and commodityName!=null'>" +
           "and commodity_name like concat('%',#{commodityName},'%') </when>" +
           "</script>")
     List<Commodity> getComodityList(Commodity commodity);


   /**
   * @Author 韩佳轩
   * @Description  根据商品列表查商品详情
   * @Date 2023/4/6 19:39
   * @Return java.util.List<com.zhuiYun.project.api.classifyshops.entity.Commodity>
   */
   @Select("SELECT * from commodity WHERE id=#{id}")
   List<Commodity> getShopsMain(Commodity commodity);


   
   /**
   * @Author 韩佳轩
   * @Description 商品详情下的评论全查
   * @Date 2023/4/9 19:17
   * @Return java.util.List<com.zhuiYun.project.api.classifyshops.entity.CommodityComment>
   * @param commodityComment
   */
   
   @Select("SELECT u.nick_name,cc.commodity_id,c.commodity_name,cc.content,cc.picture_group,cc.video_group,cc.product_description_rating,cc.create_time,u.avatar_url\n" +
           "FROM\n" +
           "\tcommodity c,\n" +
           "\tcommodity_comment cc,\n" +
           "\tuser u\n" +
           "WHERE\n" +
           "\tcc.commodity_id = c.id\n" +
           "AND cc.user_id = u.id")
  List<CommodityComment> getShopsMaincomments(CommodityComment commodityComment);

   /**
   * @Author 韩佳轩
   * @Description 计算评论里的评分
   * @Date 2023/4/11 15:51
   * @Return
   * @param commodityComment
   */
   @Select("SELECT product_description_rating from commodity_comment where id")
    List<CommodityComment> getScore(CommodityComment commodityComment);
}
